package com.factory.iamp.dao;

import com.factory.iamp.pojo.ArchiveDataLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArchiveDataLogMapper {
    @Insert("insert into archive_data_log (created_at) values (#{created_at})")
    void addLog(@Param("created_at") String created_at);

    @Select("select * from archive_data_log where created_at = #{created_at}")
    ArchiveDataLog findByDate(@Param("created_at") String created_at);

    @Select("select * from archive_data_log where created_at between #{begin} and #{end} order by lid")
    List<ArchiveDataLog> findBetweenDate(@Param("begin") String begin, @Param("end") String end);

    @Update(
            "update archive_data_log " +
            "set table_count = #{log.table_count}, problem_count = #{log.problem_count}, " +
            "problem_class_count = #{log.problem_class_count} where lid = #{log.lid}"
    )
    void updateLog(@Param("log") ArchiveDataLog log);
}
